home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / kriegspi / screen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-30  |  3.1 KB  |  118 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: screen.c,v 1.1 87/02/12 11:11:03 schoch Exp $";
  3. #endif
  4.  
  5. #include "externs.h"
  6. #include <ctype.h>
  7.  
  8. message(s, where)
  9. char *s;
  10. {
  11.  
  12.     waddstr(win[where], s);
  13. }
  14.  
  15. mclear(where)
  16. {
  17.     wclear(win[where]);
  18. }
  19.  
  20. initscreen ()
  21. {
  22.     int ww, ws1, ws2, ws3, ws;
  23.     char *termtype, *getenv();
  24.  
  25.     termtype = getenv("TERM");
  26.     vtterm = (!strncmp(termtype, "vt", 2) && !dumbterm);
  27.     if (vtterm)
  28.         COLS = 40;
  29.     if (dumbterm)
  30.         LINES = 10;
  31.     initscr();
  32.     noecho();
  33.     crmode();
  34.     if (SO == NIL || dumbterm)
  35.         reversescr = FALSE;
  36.     else
  37.         reversescr = TRUE;
  38.     if (vtterm) {
  39.         sqheight = 3;
  40.         sqwidth = 3;
  41.         sqcolor [WHITE] = ' ';
  42.         sqcolor [BLACK] = ' ';
  43.         backupscreen = newwin (LINES, COLS, 0, 0);
  44.         blankscreen = newwin (LINES, COLS, 0, 0);
  45.     } else if (reversescr) {
  46.         sqheight = 3;
  47.         sqwidth = 5;
  48.         sqcolor [WHITE] = ' ';
  49.         sqcolor [BLACK] = ' ';
  50.     } else {
  51.         sqheight = 1;
  52.         sqwidth = 2;
  53.         sqcolor [WHITE] = '.';
  54.         sqcolor [BLACK] = '*';
  55.     }
  56.     if (vtterm)
  57.         ws = sqwidth * 8 + 1;
  58.     else if (dumbterm)
  59.         ws = sqwidth * 8 + 4;
  60.     else
  61.         ws = sqwidth * 8 + 10;
  62.     ww = COLS - ws;
  63.     if (dumbterm) {
  64.         ww = ww / 3 - 1;
  65.         ws1 = ws + 1;
  66.         ws2 = ws1 + ww + 1;
  67.         ws3 = ws2 + ww + 1;
  68.         win [MYCOLOR] = subwin   (stdscr, 1, 15    ,  9,   3);
  69.         win [TOMOVE] = subwin    (stdscr, 1, ww    ,  1, ws3);
  70.         win [CLOCK] = newwin     (/*none*/1,  1    ,  1,   1);
  71.         win [CAPTURE] = subwin   (stdscr, 1, ww    ,  3, ws3);
  72.         win [PAWNTRIES] = subwin (stdscr, 1, ww    ,  4, ws3);
  73.         win [CHECK] = subwin     (stdscr, 3, ww    ,  5, ws3);
  74.         win [PROMPT] = subwin    (stdscr, 1, ww    ,  1, ws1);
  75.         win [INPUT] = subwin     (stdscr, 3, ww    ,  2, ws1);
  76.         win [LEGAL] = subwin     (stdscr, 1, ww    ,  5, ws1);
  77.         win [MESSAGE] = subwin   (stdscr, 4, ww    ,  1, ws2);
  78.         win [OPPONENT] = subwin  (stdscr, 5, ww    ,  5, ws2);
  79.         backupwin [PROMPT] = subwin    (stdscr, 1, ww    ,  1, ws1);
  80.         backupwin [MESSAGE] = subwin   (stdscr, 4, ww    ,  1, ws2);
  81.         backupwin [INPUT] = subwin     (stdscr, 3, ww    ,  2, ws1);
  82.     } else {
  83.         win [MYCOLOR] = subwin   (stdscr, 1, ww    ,  1, ws);
  84.         win [TOMOVE] = subwin    (stdscr, 1, ww - 1,  3, ws);
  85.         win [CLOCK] = subwin     (stdscr, 1,          1,  3, COLS-1);
  86.         win [CAPTURE] = subwin   (stdscr, 1, ww    ,  5, ws);
  87.         win [PAWNTRIES] = subwin (stdscr, 1, ww    ,  6, ws);
  88.         win [CHECK] = subwin     (stdscr, 3, ww    ,  7, ws);
  89.         win [PROMPT] = subwin    (stdscr, 1, ww    , 10, ws);
  90.         win [INPUT] = subwin     (stdscr, 3, ww    , 11, ws);
  91.         win [LEGAL] = subwin     (stdscr, 1, ww    , 14, ws);
  92.         win [MESSAGE] = subwin   (stdscr, 4, ww    , 15, ws);
  93.         win [OPPONENT] = subwin  (stdscr, 5, ww    , 19, ws);
  94.         scrollok (win [MESSAGE], TRUE);
  95.         scrollok (win [INPUT], TRUE);
  96.         backupwin [PROMPT] = subwin    (stdscr, 1, ww    , 10, ws);
  97.         backupwin [MESSAGE] = subwin   (stdscr, 4, ww    , 15, ws);
  98.         backupwin [INPUT] = subwin     (stdscr, 3, ww    , 11, ws);
  99.     }
  100. }
  101.  
  102. redraw_pos(pos)
  103. {
  104.     waddch(square[pos], sqcolor[(pos + pos / 10) % 2]);
  105. }
  106.  
  107. redraw_piece(pos)
  108. {
  109.     if (whose[pos] == ourcolor)
  110.         waddch(square[pos], symbol[occupant[pos]]);
  111.     else
  112.         waddch(square[pos], tolower(symbol[occupant[pos]]));
  113. }
  114.  
  115. display_capture(color, piece)
  116. {
  117. }
  118.